package hw04;

import hw04.grammar.DatalogGrammar;
import hw04.grammar.Executable;

public class Main {

	public static void main(String[] args) {
		/**/
		String input = "";
		input += "evalmode seminaive.\n";
		input += "trace on.\n";
		input += "Edge(A, B).\n";
		input += "path(x, y) :- Edge(x,y).\n";
		input += "Edge(B, C).Edge(A,C). Edge(B, A).\n";
		input += "path(x,y):-path(x,y),path(z,y).\n";
		input += "path(x,y):-Edge(x,z),Edge(z,y).\n";
		/**
		input += "path(A,_)?\n";
		input += "path(A,D). path(A, _)?\n";
		input += "path(_,_)?";
		/**/
		
		DatalogGrammar g = new DatalogGrammar();
		Executable program = g.parse(input);
		program.execute();
		/**/

		/**
		DatalogGrammar g = new DatalogGrammar();
		Scanner scan = new Scanner(System.in);
		while(scan.hasNextLine()) {
			Executable command = g.parse(scan.nextLine());
			if(command == null) {
				System.err.println("Syntax error.");
				System.exit(1);
			} else {
				command.execute();
			}
		}
		/**/
	}
	
}